#ifndef MSGD_THREAD_H
#define MSGD_THREAD_H 1

typedef void * msgd_thread_value_t;

typedef pthread_mutex_t msgd_mutex_t;
typedef pthread_cond_t  msgd_cond_t;


#ifdef __plusplus
extern "C"{
#endif

msgd_int_t msgd_init_threads(int n, size_t size);

msgd_int_t msgd_create_thread(pthread_t *tid, msgd_thread_value_t (*func)(void *arg),void *arg);

msgd_int_t msgd_cond_wait(msgd_cond_t *cv, msgd_mutex_t *m);

msgd_mutex_t *msgd_mutex_init();

msgd_int_t    msgd_mutex_trylock(msgd_mutex_t *m);

void          msgd_mutex_lock(msgd_mutex_t *m);

void          msgd_mutex_unlock(msgd_mutex_t *m);

void          msgd_mutex_destroy(msgd_mutex_t *m);


#ifdef __plusplus
}
#endif

#endif //MSGD_THREAD_H
